'use strict';

import {
    AppRegistry,
    StyleSheet,
    Text,
    TouchableOpacity,
    TextInput,
    View,
    DatePickerIOS
} from "react-native";
import React from 'react'
import MyDatePicker from './DatePicker.iOS.js'
import ModalExample from './Modal'
import PickerProvider from './PickerProvider'
import CustomAnimatedView from './CustomAnimatedSheet'
import Style from './Style'



export default class AddChildVisit extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            date: new Date(),
            showDatePicker: false,
            myTitle:"ahaha",
            myVisible:false
        }
        this.consoleChildrenSelf = this.consoleChildrenSelf.bind(this)
        this.onDateChange = this.onDateChange.bind(this);

    }

    consoleChildrenSelf() {
        // this.props.consoleMySelf()
        console.log("aahahah");
    }

    updateTitle(title) {
        this.setState({myTitle:title});
        console.log(title)
    }


    showPicker() {
        this.setState({myVisible: true});
    }

    hidePicker() {
        this.setState({myVisible: false});
    }


    onDateChange(date) {
        // console.log(dateStr)
        // this.updateTitle(dateStr)
        this.setState({date:date});
    }





    render() {
        // var showDatePicker = this.state.showDatePicker ?
        //     <DatePickerIOS
        //         style={{ height: 150 }}
        //         date={this.state.date} onDateChange={(date)=>this.setState({date})}
        //         mode="date"/> : <View />
        return (
            <View>
                <TouchableOpacity style={{marginTop:22}} onPress={() => this.showPicker()}>
                    <Text>
                        {this.state.myTitle};
                    </Text>
                </TouchableOpacity>
                <CustomAnimatedView visible={this.state.myVisible} onCancel={() => this.hidePicker()}>
                    <DatePickerIOS
                        date={this.state.date}
                        mode={"date"}
                        onDateChange={this.onDateChange}
                        style={[Style.datePicker]}
                    ></DatePickerIOS>
                </CustomAnimatedView>
            </View>
        );
    }


}

AddChildVisit.propTypes = {
    dateStr: React.PropTypes.string
}